<template>
</template>

<script>
	//选择图片
	chooseImage(){
		var count = this.pics.length
		uni.chooseImage({
			count:10-count,
			success: (res) => {
				console.log(res)
				let paths = res.tempFilePaths.map(r=>{
					return {
						type:1,
						path:r
					}
				})
				this.pics = this.pics.concat(paths)  
			}
		})
	}, 
	
	
	// 最后提交
	submit() {
		let locals = this.pics.filter(r=>{return r.type==1}).map(r=>{return r.path})
		let origins = this.pics.filter(r=>{return r.type==2}).map(r=>{return r.path})
		this.$util.uploadImages({paths:locals}).then(r=>{
			let imgs = r.data||[]
			origins = origins.concat(imgs)
			param.imgUrls = origins.join(",");
			if(that.id){
				param.id = that.id
				repaireUpdate(param).then(r=>{
					var msg = '编辑成功'
					uni.$emit('exChange')
					that.$showToast(msg)
					that.$backDelay()
				}).catch(e=>{
					console.error(e)
					that.$showToast(e.message)
				})
				return;
			}
			repaireAdd(param).then(r=>{
				var msg = '新增成功'
				uni.$emit('exChange')
				this.$showToast(msg)
				this.$backDelay()
			}).catch(e=>{
				console.error(e)
				this.$showToast(e.message)
			})
		})
	}
</script>

<style>
</style>